package cn.ven.tool;

import cn.ven.entity.MyUser;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.context.SecurityContext;
import org.springframework.security.core.context.SecurityContextHolder;

public class SessionUtil {
    //获取session
    public static MyUser getUser() {
        SecurityContext context = SecurityContextHolder.getContext();
        Authentication authentication1 = context.getAuthentication();
        MyUser user = (MyUser) authentication1.getPrincipal();
        return user;
    }
}
